#include <iostream>
using namespace std;

int n;
int QP[20];
int count;

void solve(int c) {
	if (c >= n+1) {
		count++;
		return;
	}
	for (int i=1; i<=n; i++) {
		QP[c] = i;
		bool ok = true;
		for (int j=1; j<=c-1; j++) {
			if (QP[c]==QP[j] || c-j==QP[c]-QP[j] || c-j==QP[j]-QP[c]) {
				ok = false;
				break;
			}
		}
		if (ok) {
			solve(c+1);
		}
	}
}

int main() {
	cin >> n;
	solve(1);
	cout << count << endl;
	return 0;
}
